fix(@angular/cli): support npm 12 metadata array and error formats - #33680
Merged
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the package manager parsers to support npm 12+ output formats, specifically handling metadata and errors wrapped in arrays or nested under an error property. The review feedback points out that while parseNpmLikeError was updated to handle array-wrapped errors, the corresponding unit tests only cover the error property wrapping. It is recommended to add unit tests to cover both array-wrapped errors and errors wrapped in both an array and an error property to ensure full test coverage.
In npm 12, `npm view --json <packageName> <fields>` returns package metadata formatted as an array of objects rather than a single JSON object. This caused `metadata.versions` to evaluate to `undefined` and throw `Cannot read properties of undefined (reading 'filter')` during `ng update`.
Additionally, npm 12 wraps JSON error output inside an `error` property (`{ "error": { "code": ... } }`), which is now unwrapped by `parseNpmLikeError`.
Closes angular#33679
alan-agius4
force-pushed
the
fix-npm-12-metadata
branch
from
July 30, 2026 07:17
951a7c1 to
6050d0d
Compare
crisbeto
approved these changes
Jul 30, 2026
Collaborator
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Checklist
Please check to confirm your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
In npm 12,
npm view --json <packageName> <fields>returns package metadata formatted as an array of objects rather than a single JSON object. This causedmetadata.versionsto evaluate toundefinedand throwCannot read properties of undefined (reading 'filter')duringng update.Additionally, npm 12 wraps JSON error output inside an
errorproperty ({ "error": { "code": ... } }), which was not unwrapped byparseNpmLikeError.Issue Number: Closes #33679
What is the new behavior?
parseNpmLikeMetadatanow checks ifJSON.parse(stdout)is an array and returns the first validPackageMetadataobject from the array.parseNpmLikeErrornow unwraps error objects when error JSON is wrapped in an array or an"error"property ({ "error": { ... } }).parsers_spec.tscovering npm 12+ metadata array output and error format unwrapping.Does this PR introduce a breaking change?
Other information